package com.security;


import cn.hutool.setting.Setting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConfigUtil {

    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigUtil.class);

    private Setting setting;

    private ConfigUtil() {
    }

    public void init() {
        if (setting == null) {
            setting = new Setting("config.ini");
            LOGGER.info("ConfigUtil配置文件初始化成功。");
        }
    }

    public static class ConfigUtilHolder {
        private static final ConfigUtil INSTANCE = new ConfigUtil();
    }
    public static ConfigUtil getInstance() {
        return ConfigUtilHolder.INSTANCE;
    }

    public String getByGroup(String key ,String group){
        return setting.getByGroup(key,group);
    }

    public String get(String key) {
        return setting.get(key);
    }

    public String get(String key, String defaultValue) {
        return setting.get(key, defaultValue);
    }

}
